-
Notifications
You must be signed in to change notification settings - Fork 187
Switch to the Cleaner API #1702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
Outdated
Show resolved
Hide resolved
|
@SyntevoAlex : are you interested in a review of this PR? |
|
Please proceed without me. |
|
I can have a look at this in the next days, sorry for the delayed reply. |
jonahgraham
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is great to see the removal of finalize. The not disposed reporting has been really useful. Having it be ready for the future when finalize is removed is the right step forward. Thanks for taking this on.
I have added some small suggestions/commentary.
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
Outdated
Show resolved
Hide resolved
|
@jonahgraham I think the ResourceTrackerThreadFactory should be close enough to what the InnocuousThreadFactory does. |
jonahgraham
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried out the patch on Linux and it looks good to me. I tested it both with the manual test org.eclipse.swt.tests.manual.Bug569752_DetectNonDisposedOsResources and by running the IDE (with a couple of dispose calls commented out to see the reporting in operation - and heap status on so I can trigger GC)
This looks good to me. As this code sits so completely core to everything SWT I would prefer if someone else approved too before it gets merged.
@jonahgraham I think the ResourceTrackerThreadFactory should be close enough to what the InnocuousThreadFactory does.
It looks like it to me.
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
Show resolved
Hide resolved
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java
Outdated
Show resolved
Hide resolved
|
Sorry for the last minute change. I've moved the cleaner from the Resource class to the ResourceTracker class. The advantage of this is that the cleaner thread is not started until the first instance of a ResourceTracker is created, as specified in JLS §12.4.1 |
I did a recheck with the latest commit. It looks fine to me. |
|
Missed a call to Edit: This should have no effect, since the only caller of this method never calls |
I just had a brief look and generally this looks sane, but I can have a detailed second review tomorrow. @otbutz is this an urgent change for you that should be available for the March release? If not we could postpone the submission to the beginning of the next release cycle to have more time to find potential, unexpected drawbacks. In general @otbutz could you please squash all commits into one with a commit message that covers and if necessary explains the overall change? |
|
Feel free to postpone. The current finalize-based implementation works fine, and it would be unwarranted to rush a replacement that hasn't been properly vetted. |
72dc6f8 to
ff57791
Compare
|
I've only rebased on latest SWT state. |
iloveeclipse
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Fixes #1465
finalize()by using a Cleaner insteadResourceTrackerno longer holds a reference to the resource, as the Cleaner API mandates that:nonDisposedReportershould be invoked.init()to avoid false-negatives for resources throwing an exception in their constructor. e.gnew Cursor(display, -100)